package cn.ytxy.ivos.dict.controller;


import cn.ytxy.ivos.base.response.JsonResult;
import cn.ytxy.ivos.base.response.PageData;
import cn.ytxy.ivos.dict.pojo.dto.DictQuery;
import cn.ytxy.ivos.dict.pojo.vo.DictVO;
import cn.ytxy.ivos.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;

import java.util.List;

/**
 * @ClassName DictController
 * @Description TODO
 * @Author renhong~Deng
 * @Date 2025/5/11 16:26
 * @Version 1.0
 */

@Slf4j
@RestController
@RequestMapping("/v1/dict/")
public class DictController {

    @Autowired
    private DictService dictService;

    @GetMapping("/select")
    public JsonResult selectDict(DictQuery dictQuery){
        log.info("查询字典信息,参数为：{}",dictQuery);
        PageData data = dictService.selectDict(dictQuery);
        return JsonResult.ok(data);
    }

    @PostMapping("/save")
    public JsonResult saveDict(DictQuery dictQuery){
        log.info("保存字典信息,参数为：{}",dictQuery);
        dictService.saveDict(dictQuery);
        return JsonResult.ok();
    }

    @GetMapping("/delete/{id}")
    public JsonResult deleteDict(@PathVariable Long id){
        log.info("删除字典信息,参数为：{}",id);
        dictService.deleteDict(id);
        return JsonResult.ok();
    }
}
